[アップデート] Amazon DynamoDBでトランザクション毎に最大100リクエストを実行できるようになりました

[アップデート] Amazon DynamoDBでトランザクション毎に最大100リクエストを実行できるようになりました

Clock Icon2022.09.07

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

こんにちは、CX事業本部 IoT事業部の若槻です。

このたびのアップデートにより、Amazon DynamoDBでトランザクション毎に最大100リクエストを実行できるようになりました。

今までは最大25リクエストだったので今回のアップデートにより最大数が4倍に増えた形になりますね。

Amazon DynamoDB transactions enable coordinated, all-or-nothing changes to multiple items both within and across tables. The maximum number of actions in a single transaction has now increased from 25 to 100.

そこで実際に、DynamoDBのトランザクション APIであるTransactWriteItemsを使用して上限数が100に増えたことを確認してみます。

試してみた

指定したリクエスト数のPutをTransactItemsのファイルを作成できるスクリプトです。

const fs = require('fs');

const COUNT = Number(process.argv[2]);

const array = [...Array(COUNT).keys()].map((i) => ++i);

const transactWriteItems = array.map((d) => ({
  Put: {
    Item: {
      id: { S: d.toString() },
    },
    TableName: 'dataTable',
  },
}));

const data = JSON.stringify(transactWriteItems, undefined, 2);

fs.writeFileSync('transactItems.json', data);

引数100を指定してスクリプトを実行し、リクエスト数100個のTransactItemsを作成します。

npx ts-node createTransactWriteItemsFile.ts 100

作成できました。

[
  {
    "Put": {
      "Item": {
        "id": {
          "S": "1"
        }
      },
      "TableName": "dataTable"
    }
  },
  {
    "Put": {
      "Item": {
        "id": {
          "S": "2"
        }
      },
      "TableName": "dataTable"
    }
  },
  {
    "Put": {
      "Item": {
        "id": {
          "S": "3"
        }
      },
      "TableName": "dataTable"
    }
  },
  ...(中略)
  {
    "Put": {
      "Item": {
        "id": {
          "S": "100"
        }
      },
      "TableName": "dataTable"
    }
  }
]

AWS CLIで上記ファイルを指定してTransactWriteItemsを実行します。

aws dynamodb transact-write-items \
  --transact-items file://transactItems.json

エラーなく実行できました。

テーブルを見ると100個のアイテムがPutされていますね!

次に最大リクエスト数を超える101個のリクエストを指定してTransactWriteItemsを実行してみます。

npx ts-node createTransactWriteItemsFile.ts 101

するとエラーとなりました。

aws dynamodb transact-write-items \
  --transact-items file://transactItems.json

An error occurred (ValidationException) when calling the TransactWriteItems operation: 1 validation error detected: Value '[TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a58261a}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a5829db}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a582d9c}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a58315d}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a58351e}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a5838df}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a583ca0}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a584061}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a584422}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6e6888}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6e6c49}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6e700a}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6e73cb}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6e778c}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6e7b4d}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6e7f0e}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6e82cf}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6e8690}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6e8a51}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6edce7}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6ee0a8}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6ee469}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6ee82a}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6eebeb}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6eefac}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6ef36d}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6ef72e}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6efaef}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6efeb0}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6f5146}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6f5507}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6f58c8}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6f5c89}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6f604a}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6f640b}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6f67cc}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6f6b8d}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6f6f4e}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6f730f}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6fc5a5}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6fc966}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6fcd27}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6fd0e8}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6fd4a9}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6fd86a}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6fdc2b}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6fdfec}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6fe3ad}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a6fe76e}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a703a04}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a703dc5}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a704186}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a704547}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a704908}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a704cc9}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70508a}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70544b}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70580c}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a705bcd}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70ae63}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70b224}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70b5e5}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70b9a6}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70bd67}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70c128}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70c4e9}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70c8aa}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70cc6b}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a70d02c}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a7122c2}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a712683}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a712a44}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a712e05}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a7131c6}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a713587}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a713948}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a713d09}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a7140ca}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a71448b}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a719721}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a719ae2}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a719ea3}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a71a264}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a71a625}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a71a9e6}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a71ada7}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a71b168}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a71b529}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a71b8ea}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a720b80}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a720f41}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a721302}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a7216c3}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a721a84}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a721e45}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a722206}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a7225c7}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a722988}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9a722d49}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9d2073da}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null), TransactWriteItem(conditionCheck=null, put=Put(item={id=com.amazonaws.dynamodb.v20120810.AttributeValue@9d20779b}, tableName=dataTable, conditionExpression=null, expressionAttributeNames=null, expressionAttributeValues=null, returnValuesOnConditionCheckFailure=null, workloadProfileName=null), delete=null, update=null)]' at 'transactItems' failed to satisfy constraint: Member must have length less than or equal to 100

リクエスト数が100以下の条件を満たしていないためエラーになっている旨のメッセージが表示されています。

'transactItems' failed to satisfy constraint: Member must have length less than or equal to 100

補足

BatchWriteItemを使うことも考えよう

今回は簡単のためにPutItem操作を100リクエスト行いましたが、 PutItemの単一のテーブルに対する一括実行であればBatchWriteItemでも利用可能です。(こちらはAPIコール毎のリクエスト上限は25) トランザクション処理とさせる必要がなければBatchWriteItemを使うようにしましょう。(公式でもそれがベストプラクティスとされています。)

おわりに

Amazon DynamoDBでトランザクション毎に最大100個のリクエストを実行できるようになったので試してみました。

ついこの前にAWS Step Functionsの組み込み関数States.ArrayPartitionを使ってDynamoDBのTransactWriteItems APIでリクエストするオブジェクト数を上限数25件毎に分割してみたという記事を書いたのですが、それが今回のアップデートによりもう陳腐化してしまいました。(今後はStep Functionsのペイロード256KB制限を超えない範囲で最大100件毎に分割することになりますね)昨日までの常識だった仕様が明日には通用しなくなるというAWSのサービスの進化の速さを身を持って体験しました。キャッチアップが大変ではありますが、圧倒的な供給量で技術者を常にワクワクさせてくれるのがAWSの良いところです。

参考

以上

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.